home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlib43 / mntlib / fcntl.c < prev    next >
C/C++ Source or Header  |  1993-07-09  |  571b  |  40 lines

  1. /*
  2.  * fcntl() emulation for MiNT; written by Eric R. Smith and placed
  3.  * in the public domain
  4.  */
  5.  
  6. #include <errno.h>
  7. #include <mintbind.h>
  8. #include <fcntl.h>
  9. #include <stdarg.h>
  10. #include <unistd.h>
  11.  
  12. extern int __mint;    /* MiNT version */
  13.  
  14. #ifdef __STDC__
  15. int fcntl (int f, int cmd, ...)
  16. #else
  17. int fcntl (f, cmd)
  18. int f;
  19. int cmd;
  20. #endif
  21. {
  22.     long r;
  23.     va_list argp;
  24.  
  25.     va_start(argp, cmd);
  26.  
  27.     if (__mint) {
  28.         r = Fcntl(f, va_arg(argp, void *), cmd);
  29.         if (r == -ELOCKED)
  30.             r = -EACCES;
  31.     }
  32.     else
  33.         r = -EINVAL;
  34.     if (r < 0) {
  35.         errno = (int) -r;
  36.         r = -1L;
  37.     }
  38.     return (int) r;
  39. }
  40.